import {JSEncrypt} from "jsencrypt";

/**
 * 数据加密
 * @param txt
 */
export const encrypt = (txt: any) => {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey)
    return encryptor.encrypt(txt)
}
/**
 * 解密
 * @param txt
 */
export const decrypt = (txt: any) => {
    const encryptor = new JSEncrypt()
    encryptor.setPrivateKey(privateKey)
    return encryptor.decrypt(txt)
}
const publicKey ='-----BEGIN PUBLIC KEY-----\n' +
    'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCdm4oLUPS4J0mS3rAFFOwbCign\n' +
    'msXP2chtg2XJp3gkTaUJpCvgFl6J1b4ZJGGiTq1OcV1tkdqgTDW0uazXE0jI0awu\n' +
    'PArYW8vlJ7CHbzrU0b4bPd4Nr/8xspNlLMQ2MyvR0G8vMHYUNEqSTsR4E5GxYGRH\n' +
    'sxfJ+wm8k1GC4FNSBwIDAQAB\n' +
    '-----END PUBLIC KEY-----'
const privateKey = ''
